package com.atguigu.yygh.hosp.controller;/*
 * @author: XueYouPeng
 * @time: 2023/6/12 18:27
 */


import com.atguigu.common.result.Result;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {

    @Autowired
    ScheduleService scheduleService;

    /*
     * 排班日期列表 要分页
     * @author: XueYouPeng
     * @time: 2023/6/12 18:29
     */
     @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
     public Result getScheduleRule(
             @PathVariable Integer page,
             @PathVariable Integer limit,
             @PathVariable String hoscode,
             @PathVariable String depcode
     ){
//         Map<String,Object> map = scheduleService.getScheduleRule(page,limit,hoscode,depcode);
         Map<String,Object> map = scheduleService.getScheduleRule2(page,limit,hoscode,depcode);
         return Result.ok().data(map);
     }

     /*
      * 查询日期对应的排班列表
      * @author: XueYouPeng
      * @time: 2023/6/12 19:28
      */
     @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
     public Result getScheduleDetail(
             @PathVariable String hoscode,
             @PathVariable String depcode,
             @PathVariable String workDate
     ){
         List<Schedule> scheduleList = scheduleService.getScheduleDetail(hoscode,depcode,workDate);
         return Result.ok().data("list",scheduleList);
     }

     @GetMapping("getScheduleById/{scheduleId}")
     public Result getScheduleById(@PathVariable String scheduleId){
         Schedule schedule = scheduleService.getScheduleById(scheduleId);
         return Result.ok().data("schedule",schedule);
     }

}
